import Request from '../../utils/request.js';

/**
 * 支付相关API
 */
class PaymentApi {
  /**
   * 发起微信支付
   * @param {number} activityId 活动ID
   * @param  {number} productId
   * @param  {number} plotId
   * @param  {number} areaId
   * @param {string} payType 支付类型 (wechat/alipay)
   * @returns {Promise} 返回支付信息
   */
  static async createPayment(activityId,productId,plotId,areaId, payType, quantity) {
    return Request.post('/pile/activity/pay/', {
      activityId,
      productId,
      plotId,
      areaId,
      payType,
      quantity
    });
  }

  /**
   * 查询支付状态
   * @param {string} paymentId 支付ID
   * @returns {Promise} 返回支付状态
   */
  static async getPaymentStatus(paymentId) {
    return Request.get(`/pile/activity/pay/status/${paymentId}`);
  }


  /**
   * 获取支付订单详情
   * @param {string} orderId 订单ID
   * @returns {Promise} 返回订单详情
   */
  static async getPaymentOrder(orderId) {
    return Request.get(`/pile/activity/pay/order/${orderId}`);
  }

  /**
   * 取消支付订单
   * @param {string} orderId 订单ID
   * @returns {Promise} 返回取消结果
   */
  static async cancelPaymentOrder(orderId) {
    return Request.post(`/pile/activity/pay/cancel`, {
      orderId
    });
  }
}

export default PaymentApi;